knitr::opts_chunk$set(echo = TRUE)
rm(list = ls())
most recent data Ayano shared
data <- read.csv("~/Rprojects/ayano/PES_010v6(selected).csv")
colnames(data)
[1] "Index" "ID" "Speaker" "Phase" "TimePhase" "Role"
[7] "Japanese" "English" "Functions" "Aesthetics" "User" "Vision"
[13] "Prototyping" "CA" "ALoK" "CSU" "GCA" "Projective"
[19] "Regulative" "Relational"
#time phase is tSSNA
units <- c("Speaker", "Role", "TimePhase")
codes_1 <- c("Functions", "Aesthetics", "User", "Vision", "Prototyping") # design actions codes
codes_2 <- c("CA", "ALoK", "CSU", "GCA", "Projective","Regulative","Relational") # shared epistemic agency codes
hoo_rules <- conversation_rules(
(TimePhase %in% UNIT$TimePhase & Role %in% UNIT$Role)
)
notes: accum_1 and set_1 are for design action codes; accum_2 and set_2 are for shared epistemic agency codes
accum_1 <-
contexts(data,
units_by = units,
hoo_rules = hoo_rules) %>%
accumulate_contexts(codes = codes_1,
decay.function = decay(simple_window, window_size = 4),
return.ena.set = FALSE, norm.by = NULL)
Note: Not doing means rotation so I can compare everything in the same space
set_1 <-
# model(accum_1,
# rotate.using = "mean",
# rotation.params =
# list(engineers=accum_1$meta.data$Role=="Engineer",
# servicedesigners=accum_1$meta.data$Role=="ServiceDesigner"))
model(accum_1)
accum_2 <-
contexts(data,
units_by = units,
hoo_rules = hoo_rules) %>%
accumulate_contexts(codes = codes_2,
decay.function = decay(simple_window, window_size = 4),
return.ena.set = FALSE, norm.by = NULL)
set_2 <-
# model(accum_2,
# rotate.using = "mean",
# rotation.params =
# list(engineers=accum_2$meta.data$Role=="Engineer",
# servicedesigners=accum_2$meta.data$Role=="ServiceDesigner"))
model(accum_2)
you can save set so you don’t have to run lines above next time
saveRDS(set_1, "ayano_set_1_design_codes.RDS")
saveRDS(set_2, "ayano_set_2_epistemic_codes.RDS")
global visual parameter (let’s make sure all the plots use the same level of multiplier)
node_size_multiplier = 0.3 # scale up or down node sizes
node_position_multiplier = 1 # zoom in or out node positions
point_position_multiplier = 1 # zoom in or out the point positions
edge_arrow_saturation_multiplier = 1.5 # adjust the chevron color lighter or darker
edge_size_multiplier = 1 # scale up or down edge sizes
Model 1: design action codes
Plot 1: Mean Network
plot(set_1, title = "Overall Mean") |>
units(
points= set_1$points,
point_position_multiplier = point_position_multiplier,
points_color = c("black"),
show_mean = TRUE, show_points = TRUE, with_ci = TRUE) |>
edges(
weights =set_1$line.weights,
edge_size_multiplier = edge_size_multiplier,
edge_arrow_saturation_multiplier = edge_arrow_saturation_multiplier,
node_position_multiplier = node_position_multiplier,
edge_color = c("black")) |>
nodes(
node_size_multiplier = node_size_multiplier,
node_position_multiplier = node_position_multiplier,
node_labels = TRUE, # change this to FALSE can remove node labels in case you want to add them back in a nicer font or size for your presentations or publications
self_connection_color = c("black"))
Plot 2: All Means
#get list of time phases and groups loop over or use map function
phases = unique(set_1$points$TimePhase)
groups = unique(set_1$points$Role)
# col_list = list(pd = list("darkolivegreen2","darkolivegreen3","darkolivegreen4"),
# en = list("darkorange2","darkorange3","darkorange4"),
# sd = list("darkorchid1","darkorchid2","darkorchid3"))
col_list_2 = c("red",
"blue",
"green")
# pd_colors = c("darkolivegreen2", "darkolivegreen3","darkolivegreen4")
#
# en_colors = c("darkorange2","darkorange3","darkorange4")
#
# sd_colors = c("darkorchid1","darkorchid2","darkorchid3")
x = plot(set_1, title = "Group Means by Phase")
for (i in 1:length(phases)){
for (j in 1:length(groups)){
points = set_1$points %>% filter(TimePhase == phases[i], Role == groups[j])
#print(head(points))
x = x |>
units(
points = points,
point_position_multiplier = point_position_multiplier,
points_color = col_list_2[i],
show_mean = TRUE, show_points = F, with_ci = FALSE
) |>
nodes(node_size_multiplier = 0.3,
node_position_multiplier = node_position_multiplier,
self_connection_color = c("black"))
#|>
# plotly::layout(showlegend = TRUE,
# legend = list(x = 100, y = 0.9)
# ) |>
#plotly::style(name = "test")
}
}
#x |> nodes(self_connection_color = "black")
x
# x = plot(set_1, title = "Group Means by Phase")
# points = set_1$points %>% filter(TimePhase == 1, Role == "Engineer")
#
# x |>
# units(
# points= points,
# point_position_multiplier = point_position_multiplier,
# points_color = "darkolivegreen2",
# show_mean = TRUE, show_points = TRUE, with_ci = TRUE)
Stats:
reg_dat = set_1$points %>% filter(ENA_DIRECTION == "response")
mod_x = lm(SVD1 ~ as.factor(TimePhase) + Role, data = reg_dat)
mod_y = lm(SVD2 ~ as.factor(TimePhase) + Role, data = reg_dat)
summary(mod_x)
Call:
lm(formula = SVD1 ~ as.factor(TimePhase) + Role, data = reg_dat)
Residuals:
Min 1Q Median 3Q Max
-0.76220 -0.14794 0.01651 0.16133 0.41952
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.2908 0.1177 -2.470 0.01986 *
as.factor(TimePhase)2 0.6750 0.1282 5.264 1.35e-05 ***
as.factor(TimePhase)3 1.0700 0.1315 8.135 7.42e-09 ***
RoleProductDesigner -0.2501 0.1342 -1.863 0.07292 .
RoleServiceDesigner -0.4814 0.1315 -3.660 0.00104 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.3067 on 28 degrees of freedom
Multiple R-squared: 0.7391, Adjusted R-squared: 0.7018
F-statistic: 19.83 on 4 and 28 DF, p-value: 7.679e-08
summary(mod_y)
Call:
lm(formula = SVD2 ~ as.factor(TimePhase) + Role, data = reg_dat)
Residuals:
Min 1Q Median 3Q Max
-0.36587 -0.09981 -0.02285 0.08708 0.34466
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.02159 0.07648 -0.282 0.7798
as.factor(TimePhase)2 -0.15071 0.08330 -1.809 0.0812 .
as.factor(TimePhase)3 0.16693 0.08545 1.953 0.0608 .
RoleProductDesigner 0.16092 0.08719 1.846 0.0755 .
RoleServiceDesigner -0.08909 0.08545 -1.043 0.3061
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.1993 on 28 degrees of freedom
Multiple R-squared: 0.433, Adjusted R-squared: 0.3519
F-statistic: 5.345 on 4 and 28 DF, p-value: 0.002509
Marginal means - x
library(emmeans)
emm1 = emmeans(mod_x, specs = pairwise ~ TimePhase|Role, weights = "proportional")
#emm1 = emmeans(mod_x, ~ Role*TimePhase)
#emm1$emmeans
emm1$contrasts
Role = Engineer:
contrast estimate SE df t.ratio p.value
TimePhase1 - TimePhase2 -0.675 0.128 28 -5.264 <.0001
TimePhase1 - TimePhase3 -1.070 0.132 28 -8.135 <.0001
TimePhase2 - TimePhase3 -0.395 0.134 28 -2.943 0.0172
Role = ProductDesigner:
contrast estimate SE df t.ratio p.value
TimePhase1 - TimePhase2 -0.675 0.128 28 -5.264 <.0001
TimePhase1 - TimePhase3 -1.070 0.132 28 -8.135 <.0001
TimePhase2 - TimePhase3 -0.395 0.134 28 -2.943 0.0172
Role = ServiceDesigner:
contrast estimate SE df t.ratio p.value
TimePhase1 - TimePhase2 -0.675 0.128 28 -5.264 <.0001
TimePhase1 - TimePhase3 -1.070 0.132 28 -8.135 <.0001
TimePhase2 - TimePhase3 -0.395 0.134 28 -2.943 0.0172
P value adjustment: tukey method for comparing a family of 3 estimates
#write.csv(emm1$contrasts,"emm_1_x.csv")
Marginal means - y
emm2$contrasts
contrast estimate SE df t.ratio
Engineer TimePhase1 - ProductDesigner TimePhase1 -0.16092 0.0872 28 -1.846
Engineer TimePhase1 - ServiceDesigner TimePhase1 0.08909 0.0855 28 1.043
Engineer TimePhase1 - Engineer TimePhase2 0.15071 0.0833 28 1.809
Engineer TimePhase1 - ProductDesigner TimePhase2 -0.01021 0.1176 28 -0.087
Engineer TimePhase1 - ServiceDesigner TimePhase2 0.23981 0.1164 28 2.060
Engineer TimePhase1 - Engineer TimePhase3 -0.16693 0.0855 28 -1.953
Engineer TimePhase1 - ProductDesigner TimePhase3 -0.32785 0.1220 28 -2.688
Engineer TimePhase1 - ServiceDesigner TimePhase3 -0.07784 0.1179 28 -0.660
ProductDesigner TimePhase1 - ServiceDesigner TimePhase1 0.25002 0.0833 28 3.001
ProductDesigner TimePhase1 - Engineer TimePhase2 0.31164 0.1235 28 2.524
ProductDesigner TimePhase1 - ProductDesigner TimePhase2 0.15071 0.0833 28 1.809
ProductDesigner TimePhase1 - ServiceDesigner TimePhase2 0.40073 0.1179 28 3.399
ProductDesigner TimePhase1 - Engineer TimePhase3 -0.00601 0.1222 28 -0.049
ProductDesigner TimePhase1 - ProductDesigner TimePhase3 -0.16693 0.0855 28 -1.953
ProductDesigner TimePhase1 - ServiceDesigner TimePhase3 0.08308 0.1164 28 0.714
ServiceDesigner TimePhase1 - Engineer TimePhase2 0.06162 0.1222 28 0.504
ServiceDesigner TimePhase1 - ProductDesigner TimePhase2 -0.09930 0.1177 28 -0.843
ServiceDesigner TimePhase1 - ServiceDesigner TimePhase2 0.15071 0.0833 28 1.809
ServiceDesigner TimePhase1 - Engineer TimePhase3 -0.25603 0.1237 28 -2.069
ServiceDesigner TimePhase1 - ProductDesigner TimePhase3 -0.41695 0.1222 28 -3.413
ServiceDesigner TimePhase1 - ServiceDesigner TimePhase3 -0.16693 0.0855 28 -1.953
Engineer TimePhase2 - ProductDesigner TimePhase2 -0.16092 0.0872 28 -1.846
Engineer TimePhase2 - ServiceDesigner TimePhase2 0.08909 0.0855 28 1.043
Engineer TimePhase2 - Engineer TimePhase3 -0.31765 0.0872 28 -3.643
Engineer TimePhase2 - ProductDesigner TimePhase3 -0.47857 0.1260 28 -3.797
Engineer TimePhase2 - ServiceDesigner TimePhase3 -0.22855 0.1220 28 -1.874
ProductDesigner TimePhase2 - ServiceDesigner TimePhase2 0.25002 0.0833 28 3.001
ProductDesigner TimePhase2 - Engineer TimePhase3 -0.15672 0.1205 28 -1.300
ProductDesigner TimePhase2 - ProductDesigner TimePhase3 -0.31765 0.0872 28 -3.643
ProductDesigner TimePhase2 - ServiceDesigner TimePhase3 -0.06763 0.1176 28 -0.575
ServiceDesigner TimePhase2 - Engineer TimePhase3 -0.40674 0.1222 28 -3.329
ServiceDesigner TimePhase2 - ProductDesigner TimePhase3 -0.56766 0.1235 28 -4.598
ServiceDesigner TimePhase2 - ServiceDesigner TimePhase3 -0.31765 0.0872 28 -3.643
Engineer TimePhase3 - ProductDesigner TimePhase3 -0.16092 0.0872 28 -1.846
Engineer TimePhase3 - ServiceDesigner TimePhase3 0.08909 0.0855 28 1.043
ProductDesigner TimePhase3 - ServiceDesigner TimePhase3 0.25002 0.0833 28 3.001
p.value
0.6535
0.9778
0.6761
1.0000
0.5182
0.5853
0.1975
0.9989
0.1073
0.2633
0.6761
0.0452
1.0000
0.5853
0.9982
0.9999
0.9942
0.6761
0.5123
0.0439
0.5853
0.6535
0.9778
0.0256
0.0177
0.6359
0.1073
0.9229
0.0256
0.9996
0.0530
0.0023
0.0256
0.6535
0.9778
0.1073
P value adjustment: tukey method for comparing a family of 9 estimates
Calculate eff sizes
Plot network subtractions for moderate to high eff sizes
Model 2: Epistemic Agency Codes
Plot 1: Mean Network
plot(set_2, title = "Overall Mean--Agency") |>
units(
points= set_2$points,
point_position_multiplier = point_position_multiplier,
points_color = c("black"),
show_mean = TRUE, show_points = TRUE, with_ci = TRUE) |>
edges(
weights =set_2$line.weights,
edge_size_multiplier = edge_size_multiplier,
edge_arrow_saturation_multiplier = edge_arrow_saturation_multiplier,
node_position_multiplier = node_position_multiplier,
edge_color = c("black")) |>
nodes(
node_size_multiplier = node_size_multiplier,
node_position_multiplier = node_position_multiplier,
node_labels = TRUE, # change this to FALSE can remove node labels in case you want to add them back in a nicer font or size for your presentations or publications
self_connection_color = c("black"))
Plot 2: All Means
#get list of time phases and groups loop over or use map function
phases = unique(set_2$points$TimePhase)
groups = unique(set_2$points$Role)
# col_list = list(pd = list("darkolivegreen2","darkolivegreen3","darkolivegreen4"),
# en = list("darkorange2","darkorange3","darkorange4"),
# sd = list("darkorchid1","darkorchid2","darkorchid3"))
col_list_2 = c("red",
"blue",
"green")
x_agency = plot(set_2, title = "Group Means by Phase -- Agency")
for (i in 1:length(phases)){
for (j in 1:length(groups)){
points = set_2$points %>% filter(TimePhase == phases[i], Role == groups[j])
#print(head(points))
x_agency = x_agency |>
units(
points = points,
point_position_multiplier = point_position_multiplier,
points_color = col_list_2[i],
show_mean = TRUE, show_points = F, with_ci = FALSE
) |>
nodes(node_size_multiplier = 0.3,
node_position_multiplier = node_position_multiplier,
self_connection_color = c("black"))
#|>
# plotly::layout(showlegend = TRUE,
# legend = list(x = 100, y = 0.9)
# ) |>
#plotly::style(name = "test")
}
}
x_agency
reg_dat_agency = set_2$points %>% filter(ENA_DIRECTION == "response")
mod_x_agency = lm(SVD1 ~ as.factor(TimePhase) + Role, data = reg_dat_agency)
mod_y_agency = lm(SVD2 ~ as.factor(TimePhase) + Role, data = reg_dat_agency)
summary(mod_x_agency)
Call:
lm(formula = SVD1 ~ as.factor(TimePhase) + Role, data = reg_dat_agency)
Residuals:
Min 1Q Median 3Q Max
-0.72619 -0.10243 0.00017 0.18426 0.34417
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -0.3092 0.1103 -2.804 0.00906 **
as.factor(TimePhase)2 0.6862 0.1201 5.713 3.97e-06 ***
as.factor(TimePhase)3 1.0597 0.1232 8.601 2.40e-09 ***
RoleProductDesigner -0.2519 0.1257 -2.004 0.05486 .
RoleServiceDesigner -0.4308 0.1232 -3.496 0.00159 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.2873 on 28 degrees of freedom
Multiple R-squared: 0.7564, Adjusted R-squared: 0.7216
F-statistic: 21.74 on 4 and 28 DF, p-value: 2.999e-08
summary(mod_y_agency)
Call:
lm(formula = SVD2 ~ as.factor(TimePhase) + Role, data = reg_dat_agency)
Residuals:
Min 1Q Median 3Q Max
-0.4179 -0.2658 -0.1107 0.2753 0.5530
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 0.12309 0.12362 0.996 0.32793
as.factor(TimePhase)2 0.01307 0.13464 0.097 0.92338
as.factor(TimePhase)3 -0.05497 0.13812 -0.398 0.69364
RoleProductDesigner -0.50503 0.14093 -3.584 0.00127 **
RoleServiceDesigner 0.15828 0.13812 1.146 0.26151
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.3221 on 28 degrees of freedom
Multiple R-squared: 0.4817, Adjusted R-squared: 0.4076
F-statistic: 6.505 on 4 and 28 DF, p-value: 0.0007821
Marginal means - x
library(emmeans)
emm1_agency = emmeans(mod_x_agency, specs = pairwise ~ Role:TimePhase, weights = "proportional")
#emm1 = emmeans(mod_x, ~ Role*TimePhase)
#emm1$emmeans
#emm1_agency$contrasts
write.csv(emm1_agency$contrasts,"emm_x_agency.csv")
Marginal means - y
emm2 = emmeans(mod_y_agency, specs = pairwise ~ Role:TimePhase, weights = "proportional")
#emm1 = emmeans(mod_x, ~ Role*TimePhase)
#emm2$emmeans
#emm2$contrasts
write.csv(emm2$contrasts,"emm_y_agency.csv")
Calculate eff sizes
Plot network subtractions for moderate to high eff sizes